/**
 * 
 */
package fr.gfi.agraf.vue.action.administrer.perimetre;

import java.util.ArrayList;
import java.util.List;

import fr.gfi.agraf.exception.AgrafException;
import fr.gfi.agraf.service.IPerimetreService;
import fr.gfi.agraf.utils.PropertiesUtils;
import fr.gfi.agraf.utils.SpringFactory;
import fr.gfi.agraf.vue.action.AbstractApplicationSupportAction;
import fr.gfi.agraf.vue.bean.PerimetreDTO;

/**
 * @author eleve
 * 
 */
public class VoirAdministrerPerimetreAction extends AbstractApplicationSupportAction {

	/**
	 * Généré par Java
	 */
	private static final long serialVersionUID = 548941063694761439L;

	private static final String PERIMETRE_SERVICE = "PerimetreService";

	private static final String INFOS_REGLE_SUPPRESSION = "popup.aide.administrer.perimetre.regle.suppression";

	private static final String INFOS_REGLE_SUPPRESSION_ACTIVITE = "popup.aide.administrer.perimetre.regle.suppression.activite";

	/**
	 * Liste contenant tous les périmetres
	 */
	private List<PerimetreDTO> listePerimetre;

	private List<String> listeInfoPage;

	/**
	 * Le périmetre itéré dans la jsp
	 */
	private PerimetreDTO perimetre;

	/* (non-Javadoc)
	 * @see fr.gfi.agraf.vue.action.AbstractApplicationSupportAction#executeAction()
	 */
	@Override
	public String executeAction() throws Exception {
		final IPerimetreService perimetreService = (IPerimetreService) SpringFactory.getApplicationContext()
				.getBean(PERIMETRE_SERVICE);
		try {
			listePerimetre = perimetreService.getListePerimetre();
		} catch (final AgrafException e) {
			listePerimetre = new ArrayList<PerimetreDTO>();
		}

		// Ajout des informations
		listeInfoPage = new ArrayList<String>();
		listeInfoPage.add(PropertiesUtils.getProperty(INFOS_REGLE_SUPPRESSION));
		listeInfoPage.add(PropertiesUtils.getProperty(INFOS_REGLE_SUPPRESSION_ACTIVITE));

		return SUCCESS;
	}

	public List<PerimetreDTO> getListePerimetre() {
		return listePerimetre;
	}

	/**
	 * @return the perimetre
	 */
	public PerimetreDTO getPerimetre() {
		return perimetre;
	}

	/**
	 * @param perimetre
	 *            the perimetre to set
	 */
	public void setPerimetre(final PerimetreDTO perimetre) {
		this.perimetre = perimetre;
	}

	/**
	 * @return the listeInfoPage
	 */
	public List<String> getListeInfoPage() {
		return listeInfoPage;
	}

}
